﻿using System.ComponentModel;

namespace Models
{
    /// <summary>
    /// Base class for which allows items to raise the PropertyChanged event. This is so that
    /// the derived classes can be used for data binding
    /// </summary>
    public abstract class ModelBase : INotifyPropertyChanged
    {
        /// <summary>
        /// Event raised when a property is changed
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Function called by derived classes to raise the property changed event
        /// </summary>
        /// <param name="propertyName">The name of the property that has been changed</param>
        protected void OnPropertyChanged(string propertyName)
        {
            if (!string.IsNullOrEmpty(propertyName) && (PropertyChanged != null))
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
